fix: support client aliases for subdomain email accounts#523
fix: support client aliases for subdomain email accounts#523DrBaher wants to merge 1 commit intosteipete:mainfrom
Conversation
When gog is configured with a client alias (e.g. 'company.ai') for an account whose email has a subdomain (e.g. user@sub.company.ai), auth and token resolution would fail because: 1. auth add: the email match check compared the OAuth-authorized email against the alias name, which never matched, aborting before saving the token. 2. ResolveClientForAccount: a bare string with no '@' was treated as an email with no domain, falling through to DefaultClientName instead of being used as the client name directly. Fix: - In auth_add.go: skip the email match check when c.Email has no '@', as the caller is intentionally using a client alias. - In clients.go: treat any input without '@' as a direct client name rather than attempting email/domain parsing. This allows workflows like: gog auth add company.ai --services gmail,... # sign in as user@sub.company.ai gog gmail search ... --account user@sub.company.ai # works via account_clients config Fixes auth for Workspace accounts on subdomain domains (e.g. medicus.ai).
|
Thanks for the PR. I reviewed this against current The risky bit is overloading the positional The safer supported route today is explicit client selection, e.g. |
Problem
When using
gog auth addwith a client alias for an account whose email has a subdomain (e.g.user@sub.company.ai), auth fails with:This affects any Google Workspace account on a subdomain domain (e.g.
baher@medicus.aiusing client aliasbaher.ai). Two bugs combine to cause this:auth_add.go: The OAuth-authorized email is compared against the alias name, which never matches a bare client name, so the token is never saved.clients.go:ResolveClientForAccounttreats any input without@as a malformed email with no domain, falling through toDefaultClientNameinstead of treating it as a direct client name.Fix
auth_add.go: Skip the email match check whenc.Emailhas no@— the caller is intentionally using a client alias, not an email address.clients.go: Treat any input without@as a direct client name rather than attempting email/domain parsing.Usage after fix
Tests
Added two new test cases:
TestAuthAddCmd_ClientAliasSkipsEmailCheck— verifies auth succeeds when a client alias is passedResolveClientForAccount/client name without @ is used as-is— verifies bare client name is returned directlyResolveClientForAccount/subdomain email routes via account_clients mapping— verifies subdomain email routing via configAll existing tests pass.